/**
 * Created by Administrator on 2015/1/18.
 */
var articleListApp = angular.module('articleListApp', []);

/**过滤器*/
articleListApp.filter('dayFilter',dayFilter);
/**
 * 只显示时间
 * @returns {Function}
 */
function dayFilter(){
    return function(input)
    {
        return input.split(" ")[1];
    }
}

/** 读取文章控制器 */
articleListApp.controller('listCtrl', [ '$scope', '$http', listCtrl ]);
function listCtrl($scope, $http) {

    var titles={"11":"资金流动论","22":"独家观点","21":"独家案例","31":"会员须知","32":"成为会员","33":"专享案例","34":"股票池"};

	var par = {
//		wx : GetQueryString('wxid'),
        menu : GetQueryString('menu')
	};
//    alert(par.menu+" = " +titles[par.menu]);
    document.title = titles[par.menu];
    $scope.header=titles[par.menu];
	console.log(par);
	$scope.articleList = [];
	$scope.load = function() {
		$http({
			method : 'post',
			url : '../articleList',
			params : par,
			headers : {
				'Content-Type' : 'application/x-www-form-urlencoded'
			}
		}).success(function(data, status, headers, config) {
			console.log(data);
			if (data["op.code"] == "Y") {
				// $scope.article = ;
                $scope.articleList = data["articles"];
				console.log($scope.articleList);
			} else {
//				$scope.article = data["op.info"];
				$scope.title="";
			}
		}).error(function(data, status, headers, config) {
			console.log(status);
		});
	};
	$scope.load();
}

function GetQueryString(name) {
	var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
	var r = window.location.search.substr(1).match(reg);
	if (r != null) {
		return unescape(r[2]);
	} else {
		return null;
	}
}